package com.e3.web.index.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class NavigatorModel implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5025375998957526379L;

	private String code;
	
	private String name;
	
	private String path;
	
	private boolean enable;
	
	private NavigatorModel parentModule;
	
	private List<NavigatorModel> subModels;
	
	public NavigatorModel() {
		
	}
	
	public NavigatorModel(String code) {
		this.setCode(code);
	}
	
	public String getCode(){
		return this.code;
	}
	
	public void setCode(String code){
		this.code = code;
	}
	
	public String getName(){
		return this.name;
	}
	
	public void setName(String name){
		this.name = name;
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public NavigatorModel getParentModule() {
		return parentModule;
	}

	public void setParentModule(NavigatorModel parentModule) {
		this.parentModule = parentModule;
	}

	public List<NavigatorModel> getSubModels() {
		return subModels;
	}

	public void setSubModels(List<NavigatorModel> subModels) {
		this.subModels = subModels;
	}
	
	public void addSubModel(NavigatorModel navModel){
		if(subModels == null){
			subModels = new ArrayList<NavigatorModel>();
		}
		subModels.add(navModel);
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == this){
			return true;
		}
		if(!(obj instanceof NavigatorModel)){
			return false;
		}
		
		NavigatorModel m = (NavigatorModel)obj;
		if (m != null) {
			String code1 = m.getCode();
			String code2 = getCode();
			if (code1 != null) {
				return code1.equals(code2);
			}
		}
		
		return false;
	}
	
	
}
